<%--
  Created by IntelliJ IDEA.
  User: zzz
  Date: 2020/2/7
  Time: 11:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/portal/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/portal/css/login.css"/>
</head>
<body>
<!-------------------reg-------------------------->
<div class="reg">
    <form action="${APP_PATH}/user/toRegister" method="post">
        <h1><a href="${APP_PATH}/toPortal"><img src="${APP_PATH}/portal/img/temp/logo.png"></a></h1>
        <p>用户注册</p>
        <p><input type="text" id="uemail" name="uemail" value="" placeholder="请输入邮箱"></p>
        <p><input type="password" id="upass" name="upass" value="" placeholder="请输入密码"></p>
        <p><input type="password" id="upassCheck" value="" placeholder="请确认密码"></p>
        <p class="txtL txt"><input id="checkCode" class="code" type="text" name="checkCode" value="" placeholder="验证码"><img style="margin-left: 5px; margin-top: -8px; width: 110px; height: 40px;" id="codeImg" src="${APP_PATH}/CheckCodeServlet.action"></p>
        <p><span id="error" style="color: red;">${requestScope.error}</span></p>
        <p><input type="submit" onclick="return validation()"  value="注  册"/></p>
        <p class="txtL txt">完成此注册，即表明您同意了我们的<a href="#"><使用条款和隐私策略></a></p>
        <p class="txt"><a href="${APP_PATH}/toPortalLogin"><span></span>已有账号登录</a><a style="margin-left: 20px;" href="${APP_PATH}/toPortal">返回首页</a></p>
    </form>
</div>
</body>
</html>

<script src="${APP_PATH}/portal/js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
<script>
    $(function () {
        $("#codeImg").click(function () {
            $(this).attr("src","${APP_PATH}/CheckCodeServlet.action?time="+new Date().getTime());
        });
    });
    function validation() {
        var flag = true;
        var regex =  /^[a-zA-Z0-9_+.-]+\@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,4}$/;
        if(!regex.test($("#uemail").val())){
            flag = false;
            $("#error").html("邮箱输入格式错误！");
        }
        if($("#upass").val() != $("#upassCheck").val()){
            flag = false;
            $("#error").html("两次密码输入不一致！");
        }
        if($("#uemail").val() == '' || $("#upass").val() == '' || $("#upassCheck").val() == ''){
            flag = false;
            $("#error").html("您的注册信息还没有填写完！");
        }
        if($("#checkCode").val() == ''){
            flag = false;
            $("#error").html("验证码不能为空！");
        }

        return flag;
    }
</script>